package br.org.utpr.si.seriestemporais.util;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.ArrayList;

public class Util {
	public static final int JANELA = 4;
	public static final double MAX = 240;
	public static final double MIN = 70;
	
	
	public static ArrayList<Double> lerDados(String path){
		ArrayList<Double> dados = new ArrayList<Double>();

		DecimalFormat fmt = new DecimalFormat("0.0000"); 
    	try {
			// Open the file that is the first
			// command line parameter
			FileInputStream fstream = new FileInputStream(path);
			// Get the object of DataInputStream
			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;
			// Read File Line By Line
			while ((strLine = br.readLine()) != null) {
				strLine = strLine.replace(",",".");
				double norm = Double.parseDouble(fmt.format((Double.parseDouble(strLine) - MIN)/(MAX-MIN)));
				dados.add(norm);
			}
    	}catch(Exception e){
    		System.err.println("Error: " + e.getMessage());
    	}
    	return dados;
    }
}
